package com.dzx.currentency.service.impl;

import com.dzx.currentency.annoations.DataSources;
import com.dzx.currentency.annoations.RoutingDataSource;
import com.dzx.currentency.dao.UserDao;
import com.dzx.currentency.entity.UserEntity;
import com.dzx.currentency.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author DuanZhaoXu
 * @ClassName:
 * @Description:
 * @date 2018年11月22日 09:17:53
 */
@Service
public class UserServiceImpl implements UserService {


    @Autowired
    private UserDao userDao;

    @Override
    @RoutingDataSource(value = DataSources.MASTER_DB)
    public UserEntity queryById(Integer id) {
        return userDao.queryById(id);
    }

    @Override
    @RoutingDataSource(value = DataSources.SLAVE_DB)
    public UserEntity queryByName(String name) {
        return userDao.queryByName(name);
    }

    @Override
    public int insertUser(UserEntity user) {
        return userDao.insertUser(user);
    }
}
